/*
 * @Author: your name
 * @Date: 2020-11-12 16:23:56
 * @LastEditTime: 2020-11-12 21:03:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /crowd-funding/src/utils/deviceInfo.js
 */

import { getIOSVersion, versionCompare } from '@jmfe/jm-common'

export const isAdpterBlur = function () {
	const iOSVersion = getIOSVersion()
	if (iOSVersion !== 'unknown') {
		if (versionCompare(iOSVersion, '9.2.2') > 0) {
			return false
		}
	}

	return true
}
const jugeisVersion9InIOS = function () {
	const ua = navigator.userAgent
	const match = ua.match(/OS ((\d+_?){2,3})\s/i)
	if (match) {
		const version = match[1]
		const splits = version.split('_')
		if (splits[0] > 9) {
			return true
		}
		if (splits[0] == 9) {
			if (splits.length > 1) {
				if (splits[1] >= 2) {
					return true
				}
			}
		}

		return false
	}

	return false
}

// let canvas
// let gl
// let glRenderer
// let debugInfo
// const devices = {
// 	'Apple A7 GPU': {
// 		1136: ['iPhone 5', 'iPhone 5s'],
// 		2048: ['iPad Air', 'iPad Mini 2', 'iPad Mini 3'],
// 	},

// 	'Apple A8 GPU': {
// 		1136: ['iPod touch (6th generation)'],
// 		1334: ['iPhone 6'],
// 		2001: ['iPhone 6 Plus'],
// 		2048: ['iPad Air 2', 'iPad Mini 4'],
// 	},

// 	'Apple A9 GPU': {
// 		1136: ['iPhone SE'],
// 		1334: ['iPhone 6s'],
// 		2001: ['iPhone 6s Plus'],
// 		2224: ['iPad Pro (9.7-inch)'],
// 		2732: ['iPad Pro (12.9-inch)'],
// 	},

// 	'Apple A10 GPU': {
// 		1334: ['iPhone 7'],
// 		2001: ['iPhone 7 Plus'],
// 	},

// 	// 'Apple A11 GPU': {
// 	// 	1334: ['iPhone 8'],
// 	// 	2001: ['iPhone 8 Plus'],
// 	// },
// }
// function getCanvas() {
// 	if (canvas == null) {
// 		canvas = document.createElement('canvas')
// 	}

// 	return canvas
// }
// function getGl() {
// 	try {
// 		if (gl == null) {
// 			gl = getCanvas().getContext('experimental-webgl')
// 		}
// 	} catch (error) {}

// 	return gl
// }
// function getGlRenderer() {
// 	if (glRenderer == null) {
// 		debugInfo = getGl().getExtension('WEBGL_debug_renderer_info')
// 		glRenderer =
// 			debugInfo == null ? 'unknown' : getGl().getParameter(debugInfo.UNMASKED_RENDERER_WEBGL)
// 	}
// 	return glRenderer
// }
// export const deviceInfo = function () {
// 	const key = getGlRenderer()
// 	console.log(key)
// }
